//
//  T4_1_Section_CCell.swift
//  Pods
//
//  Created by eme on 2017/4/14.
//
//

import UIKit
import RxSwift
import URLNavigator

/**
 owner:cy
 update:2017年04月14日17:09:56
 info: 首页 商品区域
 VC :  HomePageVc
 */
class T4_1_Section_CCell: UICollectionViewCell {
    
    @IBOutlet weak var products_Cv: UICollectionView!
    
    var productList = [T4ListModel]() {
        didSet {
            self.products_Cv.reloadData()
        }
    }
    override func awakeFromNib() {
        
    }
}
// MARK: - UICollectionViewDataSource
extension T4_1_Section_CCell:UICollectionViewDataSource{
    func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int{
        return self.productList.count
    }
    func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell{
        let cell = collectionView.dequeueReusableCell(withReuseIdentifier: "T4_1_CCell", for: indexPath) as!T4_1_CCell
        let item  = self.productList[indexPath.row]
        cell.item = item
        return cell
    }
    func numberOfSections(in collectionView: UICollectionView) -> Int{
        return 1
    }
}
extension T4_1_Section_CCell:UICollectionViewDelegate{
    func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath){
        let item = self.productList[indexPath.row]
         _ = "productdetail".openURL(["pdid":"\(item.pdid)"])
    }
}

extension T4_1_Section_CCell:UICollectionViewDelegateFlowLayout{
    
    func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, sizeForItemAt indexPath: IndexPath) -> CGSize{
        return T4_1_CCell.cellSize
    }
    
    func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, insetForSectionAt section: Int) -> UIEdgeInsets{
        return T4_1_CCell.cellEdgeInsets
    }
    
    func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, minimumLineSpacingForSectionAt section: Int) -> CGFloat{
        return T4_1_CCell.lineSpacing
    }
    func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, minimumInteritemSpacingForSectionAt section: Int) -> CGFloat{
        return T4_1_CCell.interitemSpacing
    }
    
    func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, referenceSizeForHeaderInSection section: Int) -> CGSize{
        return CGSize.zero
    }
    
    func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, referenceSizeForFooterInSection section: Int) -> CGSize{
        return CGSize.zero
    }
}
